package com.kyzh.core.pager.me.settings

import android.os.Bundle
import androidx.databinding.DataBindingUtil
import com.gushenge.core.dao.MMKVConsts
import com.kyzh.core.R
import com.gushenge.core.base.activity.BaseActivity
import com.kyzh.core.databinding.ActivityNoticeSettingsBinding
import com.kyzh.core.databinding.ItemSettingsSwitchBinding

class NoticeSettingsActivity : BaseActivity() {
    private lateinit var binding: ActivityNoticeSettingsBinding
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding = DataBindingUtil.setContentView(this,R.layout.activity_notice_settings)

        initView()
    }

    private fun initView() {
        binding.apply {
            vGameNotice.setInfo(getString(R.string.gameNotice), MMKVConsts.gameNotice)
            vGameNotice.sw1.setOnCheckedChangeListener { buttonView, isChecked ->
                MMKVConsts.gameNotice = isChecked
            }
            vGiftNotice.setInfo(getString(R.string.giftNotice), MMKVConsts.giftNotice)
            vGiftNotice.sw1.setOnCheckedChangeListener { buttonView, isChecked ->
                MMKVConsts.giftNotice = isChecked
            }
            vSignNotice.setInfo(getString(R.string.signNotice), MMKVConsts.signNotice)
            vSignNotice.sw1.setOnCheckedChangeListener { buttonView, isChecked ->
                MMKVConsts.signNotice = isChecked
            }
        }
    }
    private fun ItemSettingsSwitchBinding.setInfo(title:String, state:Boolean, desc:String=""){
        this.text = title
        this.sw1.isChecked = state
        this.desc = desc
    }
}